package overall.dialog
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import overall.manager.LayerManager;
	
	import starling.display.Sprite;
	import starling.text.TextField;
	import starling.utils.HAlign;
	import starling.utils.VAlign;
	
	public class DialogView extends Sprite
	{
		private var _textField:TextField;
		private var _timer:Timer;
		private var _strInfo:String;
		private var _strInfoId:int;
		public function DialogView()
		{
			super();
			var w:int=LayerManager.instance.stageWidth;
			var h:int=LayerManager.instance.stageHeight;
			_textField=new TextField(w,180,"123");
			_textField.x=0;
			_textField.y=h-160;
			_textField.border=true;
			_textField.fontSize=48;
			_textField.vAlign=VAlign.TOP;
			_textField.hAlign=HAlign.LEFT;
			addChild(_textField);
			_strInfo="";
			_strInfoId=0;
			_timer=new Timer(10);
			_timer.addEventListener(TimerEvent.TIMER,_timerRun);
		}
		public function set text(str:String):void
		{
			_strInfo=str;
			_textField.text="";
			_strInfoId=0;
			_timer.start();
		}
		
		
		private function _timerRun(e:TimerEvent):void
		{
			_textField.text=_textField.text.concat(_strInfo.charAt(_strInfoId));
			_strInfoId+=1;
			if(_strInfoId==_strInfo.length){
				_timer.reset();
				_timer.stop();
			}
		}
								 
	}
}